//
//  DefineConstant.h
//  Nooryes
//
//  Created by baken on 2020/2/25.
//  Copyright © 2020 MyApp. All rights reserved.
//

typedef NS_ENUM(NSInteger, U9NetworkStatus) {
    NetworkStatusUnknown          = -1,
    NetworkStatusNotReachable     = 0,
    NetworkStatusReachableViaWWAN = 1,
    NetworkStatusReachableViaWiFi = 2,
};


typedef NS_ENUM(NSInteger,AlertImageType) {
    AlertSuccess,
    AlertLogin,
    AlertGuess,
    AlertFail
    
};


typedef NS_ENUM(NSUInteger,NewsType) {
    NewsTypeScroll, // 滚动图
    NewsTypeMatch, // 比赛
    NewsTypePerson, // 个人直播
    NewsTypeNews, // 新闻（有图）
    NewsTypeAdvertisement // 广告
};

typedef enum {
    RefreshDarkStyle,
    RefreshLightStyle,
} U9RefreshStyle;




typedef NS_ENUM(NSInteger, TaskType) {
    TaskLogin = 0,
    TaskShareMatch = 1,
    TaskPlaceTwo =2,
    TaskPlaceTir = 3,
    TaskCommentNews = 4,
    TaskShareNews = 5,
    TaskGuessMatch = 6,
    TaskCommentMatch = 7
    
};


#define kSecretKey @"jIaNgSuYcNlInGiNjIaNgSuYiNlInGjIjIcN"

//判断是否为空或是[NSNull null]
#define NotNilAndNull(_ref) (((_ref) != nil) && (![(_ref) isEqual:[NSNull null]]))
#define IsNilOrNull(_ref)   (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]))

//判断字符串是否为空
#define IsStrEmpty(_ref)    (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) || ([(_ref)isEqualToString:@""]))

//判断数组是否为空
#define IsArrayEmpty(_ref)  (((_ref) == nil) || ([(_ref) count] == 0) || ([(_ref) isEqual:[NSNull null]]))

//16进制颜色
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]


//创建NSNumber类型
#undef  __INT
#define __INT (__x)             [NSNumber numberWithInteger:(NSInteger)__x]

#undef  __UINT
#define __UINT (__x)            [NSNumber numberWithUnsignedInteger:(NSUInteger)__x]

#undef  __FLOAT
#define __FLOAT (__x)           [NSNumber numberWithFloat:(float)__x]

#undef  __DOUBLE
#define __DOUBLE (__x)          [NSNumber numberWithDouble:(double)__x]


//创建NSString
#undef  STR_FROM_INT
#define STR_FROM_INT( __x )      [NSString stringWithFormat:@"%ld",(long)(__x)]


//多线程执行方法
#define Foreground_Begin        dispatch_async(dispatch_get_main_queue(),^{
#define Foreground_End          });

#define Background_Begin        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{\
@autoreleasepool{
#define Background_End                  }\
});


#undef  AS_SINGLETON
#define AS_SINGLETON( __class ) \
+ (__class)sharedInstance;

#undef  DEF_SINGLETON
#define DEF_SINGLETON(__class)  \
+ (__class)sharedInstance   \
{   \
static dispatch_once_t t;   \
static __class *__singleton__;  \
static dispatch_once(&t,^{__singleton__ = [[__class alloc] init];});\
return __singleton__;\
}



#define DEVICE_TYPE_IPAD  ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)


#define IsNullObj(____object____) ((____object____ && [____object____ isKindOfClass: [NSNull class]]) || (____object____ == nil))

#define getStr(obj)    ((IsNullObj(obj))?(@""):([NSString stringWithFormat:@"%@",obj]))



//由角度转换弧度

#define DegreesToRadian(x) (M_PI * (x) / 180.0)



//由弧度转换角度

#define RadianToDegrees(radian) (radian*180.0)/(M_PI)





